package com.alibaba.datax.plugin.reader.mysqlreader;

import com.alibaba.datax.plugin.rdbms.reader.CommonRdbmsReader;
import com.alibaba.datax.plugin.rdbms.reader.Constant;
import com.alibaba.datax.plugin.rdbms.util.DataBaseType;
import com.health.trans.common.entity.RecordSender;
import com.health.trans.common.util.Configuration;

public class MysqlReader {

    private static final DataBaseType DATABASE_TYPE = DataBaseType.MySql;


    public static class Task {

        private Configuration readerSliceConfig;
        private CommonRdbmsReader.Task commonRdbmsReaderTask;

        public void init( Configuration configuration) {
            this.commonRdbmsReaderTask = new CommonRdbmsReader.Task(DATABASE_TYPE,36, 66);
            Configuration configuration1 = configuration.getListConfiguration("job.content").get(0).getConfiguration("reader.parameter");
            this.readerSliceConfig=configuration1;
            this.commonRdbmsReaderTask.init(configuration1);
        }

        public void startRead(RecordSender recordSender) {
            int fetchSize =1000;
            this.commonRdbmsReaderTask.startRead(this.readerSliceConfig, recordSender, fetchSize);
        }

        public void post() {
            this.commonRdbmsReaderTask.post(this.readerSliceConfig);
        }

        public void destroy() {
            this.commonRdbmsReaderTask.destroy(this.readerSliceConfig);
        }

    }

}
